/* eslint-disable */
const webpack = require("webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
// const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");
const ESLintPlugin = require("eslint-webpack-plugin");

var main = {
  target: "electron-main",
  entry: path.join(__dirname, "../src/main/app.ts"), //"./src/app.ts",
  devtool: "inline-source-map",
  plugins: [
    new CleanWebpackPlugin(),
    new ESLintPlugin({
      overrideConfigFile: path.join(__dirname, "main.eslintrc"),
      fix: false,
      extensions: [".js", ".jsx", ".vue", ".ts", ".tsx"],
      cache: true,
      emitWarning: false,
      emitError: false,
      formatter: undefined
    })
  ],
  module: {
    rules: [
      {
        test: /\.ts?$/,
        use: [
          {
            loader: "cache-loader"
          },
          {
            loader: "thread-loader"
          }
          // ,
          // {
          //   loader: "ts-loader",
          //   options: {
          //     configFile: path.join(__dirname, "tsconfig.json"),
          //     transpileOnly: true,
          //     appendTsSuffixTo: ["\\.vue$"],
          //     happyPackMode: true
          //   }
          // }
        ]
      },
      {
        test: /\.(js|vue|ts|tsx|jsx)$/,
        enforce: "pre",
        exclude: /node_modules/,
        use: [
          {
            loader: "eslint-loader",
            options: {
              overrideConfigFile: path.join(__dirname, "main.eslintrc")
            }
          }
        ]
      }
    ]
  },
  resolve: {
    extensions: [".tsx", ".ts", ".js"]
    // plugins: [new TsconfigPathsPlugin({ configFile: path.join(__dirname, "tsconfig.json") })]
  },
  node: {
    __filename: false,
    __dirname: false,
    setImmediate: false,
    fs: "empty",
    net: "empty",
    tls: "empty"
  },
  output: {
    path: path.resolve(__dirname, "../build"),
    filename: "app.js"
  }
};

module.exports = main;
